/**
 * WhiMAIcpp - C++ interface for the Whiskey Media API's.
 *  Copyright (C) 2010  Anders Bugge
 *
 *  Data created and powered by:
 *  Whiskey Media	http://www.whiskeymedia.com/
 *  Giant Bomb		http://www.giantbomb.com/
 *  Comic Vine		http://www.comicvine.com/
 */

#ifndef INTERFACE_H_
#define INTERFACE_H_

// STL
#include <string>


namespace WM
{

/// The API interface
/**
 * Interface towards the Whiskey Media APIs.
 */
class Interface
{
public:
	/**
	 * @return pointer to Interface.
	 */
	static Interface* Instance();	///< Call to get access to the Interface
	static void Release();	///< Call release when done using the Interface

	/**
	 * @param data reference to data storage.
	 * @param url reference to request URL.
	 * @return error return code from cURL, see curl.h for more info.
	 */
	unsigned int getData( std::string& data, const std::string& url ); ///< Make API request

private:
	static Interface* instance;	///< Pointer to the single instance of Interface
	static int count;	///< Access counter, used for memory management

	Interface();
	virtual ~Interface();

	static size_t write_data( void *ptr, size_t size, size_t nmemb, void *ourpointer ); ///< Callback from cURL
	std::string json;	///< response data

	void* curl_handle;	///< cURL handler
};

} // VMA

#endif /* INTERFACE_H_ */
